<?php
	/**
	 * The abstract TableProjectBidGen class defined here is
	 * code-generated and contains all the basic CRUD-type functionality as well as
	 * basic methods to handle relationships and index-based loading.
	 *
	 * To use, you should use the TableProjectBid subclass which
	 * extends this TableProjectBidGen class.
	 *
	 * Because subsequent re-code generations will overwrite any changes to this
	 * file, you should leave this file unaltered to prevent yourself from losing
	 * any information or code changes.  All customizations should be done by
	 * overriding existing or implementing new methods, properties and variables
	 * in the TableProjectBid class.
	 * 
	 * @package My Application
	 * @subpackage GeneratedDataObjects
	 * @property-read integer $Id the value for intId (Read-Only PK)
	 * @property integer $UserId the value for intUserId (Not Null)
	 * @property integer $ProjectId the value for intProjectId (Not Null)
	 * @property integer $BuyerId the value for intBuyerId (Not Null)
	 * @property integer $Bid the value for intBid (Not Null)
	 * @property integer $DayToComplete the value for intDayToComplete (Not Null)
	 * @property integer $DayPeriodBeforeStarting the value for intDayPeriodBeforeStarting (Not Null)
	 * @property string $Comment the value for strComment 
	 * @property string $Sendmail the value for strSendmail 
	 * @property string $Enable the value for strEnable (Not Null)
	 * @property QDateTime $BidDate the value for dttBidDate 
	 * @property QDateTime $RetractDate the value for dttRetractDate 
	 * @property string $Won the value for strWon 
	 * @property string $Retract the value for strRetract 
	 * @property integer $Status the value for intStatus (Not Null)
	 * @property TableUserProject $User the value for the TableUserProject object referenced by intUserId (Not Null)
	 * @property TableProject $Project the value for the TableProject object referenced by intProjectId (Not Null)
	 * @property-read boolean $__Restored whether or not this object was restored from the database (as opposed to created new)
	 */
	class TableProjectBidGen extends QBaseClass {

		///////////////////////////////////////////////////////////////////////
		// PROTECTED MEMBER VARIABLES and TEXT FIELD MAXLENGTHS (if applicable)
		///////////////////////////////////////////////////////////////////////
		
		/**
		 * Protected member variable that maps to the database PK Identity column table_project_bid.id
		 * @var integer intId
		 */
		protected $intId;
		const IdDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_project_bid.user_id
		 * @var integer intUserId
		 */
		protected $intUserId;
		const UserIdDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_project_bid.project_id
		 * @var integer intProjectId
		 */
		protected $intProjectId;
		const ProjectIdDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_project_bid.buyer_id
		 * @var integer intBuyerId
		 */
		protected $intBuyerId;
		const BuyerIdDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_project_bid.bid
		 * @var integer intBid
		 */
		protected $intBid;
		const BidDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_project_bid.day_to_complete
		 * @var integer intDayToComplete
		 */
		protected $intDayToComplete;
		const DayToCompleteDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_project_bid.day_period_before_starting
		 * @var integer intDayPeriodBeforeStarting
		 */
		protected $intDayPeriodBeforeStarting;
		const DayPeriodBeforeStartingDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_project_bid.comment
		 * @var string strComment
		 */
		protected $strComment;
		const CommentMaxLength = 255;
		const CommentDefault = null;


		/**
		 * Protected member variable that maps to the database column table_project_bid.sendmail
		 * @var string strSendmail
		 */
		protected $strSendmail;
		const SendmailMaxLength = 1;
		const SendmailDefault = null;


		/**
		 * Protected member variable that maps to the database column table_project_bid.enable
		 * @var string strEnable
		 */
		protected $strEnable;
		const EnableMaxLength = 1;
		const EnableDefault = null;


		/**
		 * Protected member variable that maps to the database column table_project_bid.bid_date
		 * @var QDateTime dttBidDate
		 */
		protected $dttBidDate;
		const BidDateDefault = null;


		/**
		 * Protected member variable that maps to the database column table_project_bid.retract_date
		 * @var QDateTime dttRetractDate
		 */
		protected $dttRetractDate;
		const RetractDateDefault = null;


		/**
		 * Protected member variable that maps to the database column table_project_bid.won
		 * @var string strWon
		 */
		protected $strWon;
		const WonMaxLength = 1;
		const WonDefault = 'n';


		/**
		 * Protected member variable that maps to the database column table_project_bid.retract
		 * @var string strRetract
		 */
		protected $strRetract;
		const RetractMaxLength = 1;
		const RetractDefault = 'n';


		/**
		 * Protected member variable that maps to the database column table_project_bid.status
		 * @var integer intStatus
		 */
		protected $intStatus;
		const StatusDefault = 0;


		/**
		 * Protected array of virtual attributes for this object (e.g. extra/other calculated and/or non-object bound
		 * columns from the run-time database query result for this object).  Used by InstantiateDbRow and
		 * GetVirtualAttribute.
		 * @var string[] $__strVirtualAttributeArray
		 */
		protected $__strVirtualAttributeArray = array();

		/**
		 * Protected internal member variable that specifies whether or not this object is Restored from the database.
		 * Used by Save() to determine if Save() should perform a db UPDATE or INSERT.
		 * @var bool __blnRestored;
		 */
		protected $__blnRestored;




		///////////////////////////////
		// PROTECTED MEMBER OBJECTS
		///////////////////////////////

		/**
		 * Protected member variable that contains the object pointed by the reference
		 * in the database column table_project_bid.user_id.
		 *
		 * NOTE: Always use the User property getter to correctly retrieve this TableUserProject object.
		 * (Because this class implements late binding, this variable reference MAY be null.)
		 * @var TableUserProject objUser
		 */
		protected $objUser;

		/**
		 * Protected member variable that contains the object pointed by the reference
		 * in the database column table_project_bid.project_id.
		 *
		 * NOTE: Always use the Project property getter to correctly retrieve this TableProject object.
		 * (Because this class implements late binding, this variable reference MAY be null.)
		 * @var TableProject objProject
		 */
		protected $objProject;





		///////////////////////////////
		// CLASS-WIDE LOAD AND COUNT METHODS
		///////////////////////////////

		/**
		 * Static method to retrieve the Database object that owns this class.
		 * @return QDatabaseBase reference to the Database object that can query this class
		 */
		public static function GetDatabase() {
			return QApplication::$Database[1];
		}

		/**
		 * Load a TableProjectBid from PK Info
		 * @param integer $intId
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableProjectBid
		 */
		public static function Load($intId, $objOptionalClauses = null) {
			// Use QuerySingle to Perform the Query
			return TableProjectBid::QuerySingle(
				QQ::AndCondition(
					QQ::Equal(QQN::TableProjectBid()->Id, $intId)
				),
				$objOptionalClauses
			);
		}

		/**
		 * Load all TableProjectBids
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableProjectBid[]
		 */
		public static function LoadAll($objOptionalClauses = null) {
			if (func_num_args() > 1) {
				throw new QCallerException("LoadAll must be called with an array of optional clauses as a single argument");
			}
			// Call TableProjectBid::QueryArray to perform the LoadAll query
			try {
				return TableProjectBid::QueryArray(QQ::All(), $objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count all TableProjectBids
		 * @return int
		 */
		public static function CountAll() {
			// Call TableProjectBid::QueryCount to perform the CountAll query
			return TableProjectBid::QueryCount(QQ::All());
		}




		///////////////////////////////
		// QCUBED QUERY-RELATED METHODS
		///////////////////////////////

		/**
		 * Internally called method to assist with calling Qcubed Query for this class
		 * on load methods.
		 * @param QQueryBuilder &$objQueryBuilder the QueryBuilder object that will be created
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause object or array of QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with (sending in null will skip the PrepareStatement step)
		 * @param boolean $blnCountOnly only select a rowcount
		 * @return string the query statement
		 */
		protected static function BuildQueryStatement(&$objQueryBuilder, QQCondition $objConditions, $objOptionalClauses, $mixParameterArray, $blnCountOnly) {
			// Get the Database Object for this Class
			$objDatabase = TableProjectBid::GetDatabase();

			// Create/Build out the QueryBuilder object with TableProjectBid-specific SELET and FROM fields
			$objQueryBuilder = new QQueryBuilder($objDatabase, 'table_project_bid');
			TableProjectBid::GetSelectFields($objQueryBuilder);
			$objQueryBuilder->AddFromItem('table_project_bid');

			// Set "CountOnly" option (if applicable)
			if ($blnCountOnly)
				$objQueryBuilder->SetCountOnlyFlag();

			// Apply Any Conditions
			if ($objConditions)
				try {
					$objConditions->UpdateQueryBuilder($objQueryBuilder);
				} catch (QCallerException $objExc) {
					$objExc->IncrementOffset();
					throw $objExc;
				}

			// Iterate through all the Optional Clauses (if any) and perform accordingly
			if ($objOptionalClauses) {
				if ($objOptionalClauses instanceof QQClause)
					$objOptionalClauses->UpdateQueryBuilder($objQueryBuilder);
				else if (is_array($objOptionalClauses))
					foreach ($objOptionalClauses as $objClause)
						$objClause->UpdateQueryBuilder($objQueryBuilder);
				else
					throw new QCallerException('Optional Clauses must be a QQClause object or an array of QQClause objects');
			}

			// Get the SQL Statement
			$strQuery = $objQueryBuilder->GetStatement();

			// Prepare the Statement with the Query Parameters (if applicable)
			if ($mixParameterArray) {
				if (is_array($mixParameterArray)) {
					if (count($mixParameterArray))
						$strQuery = $objDatabase->PrepareStatement($strQuery, $mixParameterArray);

					// Ensure that there are no other Unresolved Named Parameters
					if (strpos($strQuery, chr(QQNamedValue::DelimiterCode) . '{') !== false)
						throw new QCallerException('Unresolved named parameters in the query');
				} else
					throw new QCallerException('Parameter Array must be an array of name-value parameter pairs');
			}

			// Return the Objects
			return $strQuery;
		}

		/**
		 * Static Qcubed Query method to query for a single TableProjectBid object.
		 * Uses BuildQueryStatment to perform most of the work.
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
		 * @return TableProjectBid the queried object
		 */
		public static function QuerySingle(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
			// Get the Query Statement
			try {
				$strQuery = TableProjectBid::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
			
			// Perform the Query, Get the First Row, and Instantiate a new TableProjectBid object
			$objDbResult = $objQueryBuilder->Database->Query($strQuery);
			
			// Do we have to expand anything?
			if ($objQueryBuilder->ExpandAsArrayNodes) {
				$objToReturn = array();
				while ($objDbRow = $objDbResult->GetNextRow()) {
					$objItem = TableProjectBid::InstantiateDbRow($objDbRow, null, $objQueryBuilder->ExpandAsArrayNodes, $objToReturn, $objQueryBuilder->ColumnAliasArray);
					if ($objItem)
						$objToReturn[] = $objItem;					
				}			
				// Since we only want the object to return, lets return the object and not the array.
				return $objToReturn[0];
			} else {
				// No expands just return the first row
				$objToReturn = null;
				while ($objDbRow = $objDbResult->GetNextRow())
					$objToReturn = TableProjectBid::InstantiateDbRow($objDbRow, null, null, null, $objQueryBuilder->ColumnAliasArray);
			}
			
			return $objToReturn;
		}

		/**
		 * Static Qcubed Query method to query for an array of TableProjectBid objects.
		 * Uses BuildQueryStatment to perform most of the work.
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
		 * @return TableProjectBid[] the queried objects as an array
		 */
		public static function QueryArray(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
			// Get the Query Statement
			try {
				$strQuery = TableProjectBid::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Perform the Query and Instantiate the Array Result
			$objDbResult = $objQueryBuilder->Database->Query($strQuery);
			return TableProjectBid::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
		}

		/**
		 * Static Qcubed Query method to query for a count of TableProjectBid objects.
		 * Uses BuildQueryStatment to perform most of the work.
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
		 * @return integer the count of queried objects as an integer
		 */
		public static function QueryCount(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
			// Get the Query Statement
			try {
				$strQuery = TableProjectBid::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, true);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Perform the Query and return the row_count
			$objDbResult = $objQueryBuilder->Database->Query($strQuery);

			// Figure out if the query is using GroupBy
			$blnGrouped = false;

			if ($objOptionalClauses) foreach ($objOptionalClauses as $objClause) {
				if ($objClause instanceof QQGroupBy) {
					$blnGrouped = true;
					break;
				}
			}

			if ($blnGrouped)
				// Groups in this query - return the count of Groups (which is the count of all rows)
				return $objDbResult->CountRows();
			else {
				// No Groups - return the sql-calculated count(*) value
				$strDbRow = $objDbResult->FetchRow();
				return QType::Cast($strDbRow[0], QType::Integer);
			}
		}

		public static function QueryArrayCached(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null, $blnForceUpdate = false) {
			// Get the Database Object for this Class
			$objDatabase = TableProjectBid::GetDatabase();

			$strQuery = TableProjectBid::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
			
			$objCache = new QCache('qquery/tableprojectbid', $strQuery);
			$cacheData = $objCache->GetData();
			
			if (!$cacheData || $blnForceUpdate) {
				$objDbResult = $objQueryBuilder->Database->Query($strQuery);
				$arrResult = TableProjectBid::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
				$objCache->SaveData(serialize($arrResult));
			} else {
				$arrResult = unserialize($cacheData);
			}
			
			return $arrResult;
		}

		/**
		 * Updates a QQueryBuilder with the SELECT fields for this TableProjectBid
		 * @param QQueryBuilder $objBuilder the Query Builder object to update
		 * @param string $strPrefix optional prefix to add to the SELECT fields
		 */
		public static function GetSelectFields(QQueryBuilder $objBuilder, $strPrefix = null) {
			if ($strPrefix) {
				$strTableName = $strPrefix;
				$strAliasPrefix = $strPrefix . '__';
			} else {
				$strTableName = 'table_project_bid';
				$strAliasPrefix = '';
			}

			$objBuilder->AddSelectItem($strTableName, 'id', $strAliasPrefix . 'id');
			$objBuilder->AddSelectItem($strTableName, 'user_id', $strAliasPrefix . 'user_id');
			$objBuilder->AddSelectItem($strTableName, 'project_id', $strAliasPrefix . 'project_id');
			$objBuilder->AddSelectItem($strTableName, 'buyer_id', $strAliasPrefix . 'buyer_id');
			$objBuilder->AddSelectItem($strTableName, 'bid', $strAliasPrefix . 'bid');
			$objBuilder->AddSelectItem($strTableName, 'day_to_complete', $strAliasPrefix . 'day_to_complete');
			$objBuilder->AddSelectItem($strTableName, 'day_period_before_starting', $strAliasPrefix . 'day_period_before_starting');
			$objBuilder->AddSelectItem($strTableName, 'comment', $strAliasPrefix . 'comment');
			$objBuilder->AddSelectItem($strTableName, 'sendmail', $strAliasPrefix . 'sendmail');
			$objBuilder->AddSelectItem($strTableName, 'enable', $strAliasPrefix . 'enable');
			$objBuilder->AddSelectItem($strTableName, 'bid_date', $strAliasPrefix . 'bid_date');
			$objBuilder->AddSelectItem($strTableName, 'retract_date', $strAliasPrefix . 'retract_date');
			$objBuilder->AddSelectItem($strTableName, 'won', $strAliasPrefix . 'won');
			$objBuilder->AddSelectItem($strTableName, 'retract', $strAliasPrefix . 'retract');
			$objBuilder->AddSelectItem($strTableName, 'status', $strAliasPrefix . 'status');
		}



		///////////////////////////////
		// INSTANTIATION-RELATED METHODS
		///////////////////////////////

		/**
		 * Instantiate a TableProjectBid from a Database Row.
		 * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
		 * is calling this TableProjectBid::InstantiateDbRow in order to perform
		 * early binding on referenced objects.
		 * @param DatabaseRowBase $objDbRow
		 * @param string $strAliasPrefix
		 * @param string $strExpandAsArrayNodes
		 * @param QBaseClass $arrPreviousItem
		 * @param string[] $strColumnAliasArray
		 * @return TableProjectBid
		*/
		public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $arrPreviousItems = null, $strColumnAliasArray = array()) {
			// If blank row, return null
			if (!$objDbRow) {
				return null;
			}

			// Create a new instance of the TableProjectBid object
			$objToReturn = new TableProjectBid();
			$objToReturn->__blnRestored = true;

			$strAliasName = array_key_exists($strAliasPrefix . 'id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'id'] : $strAliasPrefix . 'id';
			$objToReturn->intId = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'user_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'user_id'] : $strAliasPrefix . 'user_id';
			$objToReturn->intUserId = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'project_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'project_id'] : $strAliasPrefix . 'project_id';
			$objToReturn->intProjectId = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'buyer_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'buyer_id'] : $strAliasPrefix . 'buyer_id';
			$objToReturn->intBuyerId = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'bid', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'bid'] : $strAliasPrefix . 'bid';
			$objToReturn->intBid = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'day_to_complete', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'day_to_complete'] : $strAliasPrefix . 'day_to_complete';
			$objToReturn->intDayToComplete = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'day_period_before_starting', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'day_period_before_starting'] : $strAliasPrefix . 'day_period_before_starting';
			$objToReturn->intDayPeriodBeforeStarting = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'comment', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'comment'] : $strAliasPrefix . 'comment';
			$objToReturn->strComment = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'sendmail', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'sendmail'] : $strAliasPrefix . 'sendmail';
			$objToReturn->strSendmail = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'enable', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'enable'] : $strAliasPrefix . 'enable';
			$objToReturn->strEnable = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'bid_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'bid_date'] : $strAliasPrefix . 'bid_date';
			$objToReturn->dttBidDate = $objDbRow->GetColumn($strAliasName, 'DateTime');
			$strAliasName = array_key_exists($strAliasPrefix . 'retract_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'retract_date'] : $strAliasPrefix . 'retract_date';
			$objToReturn->dttRetractDate = $objDbRow->GetColumn($strAliasName, 'DateTime');
			$strAliasName = array_key_exists($strAliasPrefix . 'won', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'won'] : $strAliasPrefix . 'won';
			$objToReturn->strWon = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'retract', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'retract'] : $strAliasPrefix . 'retract';
			$objToReturn->strRetract = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'status', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'status'] : $strAliasPrefix . 'status';
			$objToReturn->intStatus = $objDbRow->GetColumn($strAliasName, 'Integer');

			if (isset($arrPreviousItems) && is_array($arrPreviousItems)) {
				foreach ($arrPreviousItems as $objPreviousItem) {
					if ($objToReturn->Id != $objPreviousItem->Id) {
						continue;
					}

					// complete match - all primary key columns are the same
					return null;
				}
			}

			// Instantiate Virtual Attributes
			foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
				$strVirtualPrefix = $strAliasPrefix . '__';
				$strVirtualPrefixLength = strlen($strVirtualPrefix);
				if (substr($strColumnName, 0, $strVirtualPrefixLength) == $strVirtualPrefix)
					$objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
			}

			// Prepare to Check for Early/Virtual Binding
			if (!$strAliasPrefix)
				$strAliasPrefix = 'table_project_bid__';

			// Check for User Early Binding
			$strAlias = $strAliasPrefix . 'user_id__id';
			$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
			if (!is_null($objDbRow->GetColumn($strAliasName)))
				$objToReturn->objUser = TableUserProject::InstantiateDbRow($objDbRow, $strAliasPrefix . 'user_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);

			// Check for Project Early Binding
			$strAlias = $strAliasPrefix . 'project_id__id';
			$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
			if (!is_null($objDbRow->GetColumn($strAliasName)))
				$objToReturn->objProject = TableProject::InstantiateDbRow($objDbRow, $strAliasPrefix . 'project_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);




			return $objToReturn;
		}

		/**
		 * Instantiate an array of TableProjectBids from a Database Result
		 * @param DatabaseResultBase $objDbResult
		 * @param string $strExpandAsArrayNodes
		 * @param string[] $strColumnAliasArray
		 * @return TableProjectBid[]
		 */
		public static function InstantiateDbResult(QDatabaseResultBase $objDbResult, $strExpandAsArrayNodes = null, $strColumnAliasArray = null) {
			$objToReturn = array();
			
			if (!$strColumnAliasArray)
				$strColumnAliasArray = array();

			// If blank resultset, then return empty array
			if (!$objDbResult)
				return $objToReturn;

			// Load up the return array with each row
			if ($strExpandAsArrayNodes) {
				$objToReturn = array();
				while ($objDbRow = $objDbResult->GetNextRow()) {
					$objItem = TableProjectBid::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objToReturn, $strColumnAliasArray);
					if ($objItem) {
						$objToReturn[] = $objItem;
					}
				}
			} else {
				while ($objDbRow = $objDbResult->GetNextRow())
					$objToReturn[] = TableProjectBid::InstantiateDbRow($objDbRow, null, null, null, $strColumnAliasArray);
			}

			return $objToReturn;
		}



		///////////////////////////////////////////////////
		// INDEX-BASED LOAD METHODS (Single Load and Array)
		///////////////////////////////////////////////////
			
		/**
		 * Load a single TableProjectBid object,
		 * by Id Index(es)
		 * @param integer $intId
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableProjectBid
		*/
		public static function LoadById($intId, $objOptionalClauses = null) {
			return TableProjectBid::QuerySingle(
				QQ::AndCondition(
					QQ::Equal(QQN::TableProjectBid()->Id, $intId)
				),
				$objOptionalClauses
			);
		}
			
		/**
		 * Load an array of TableProjectBid objects,
		 * by UserId Index(es)
		 * @param integer $intUserId
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableProjectBid[]
		*/
		public static function LoadArrayByUserId($intUserId, $objOptionalClauses = null) {
			// Call TableProjectBid::QueryArray to perform the LoadArrayByUserId query
			try {
				return TableProjectBid::QueryArray(
					QQ::Equal(QQN::TableProjectBid()->UserId, $intUserId),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableProjectBids
		 * by UserId Index(es)
		 * @param integer $intUserId
		 * @return int
		*/
		public static function CountByUserId($intUserId) {
			// Call TableProjectBid::QueryCount to perform the CountByUserId query
			return TableProjectBid::QueryCount(
				QQ::Equal(QQN::TableProjectBid()->UserId, $intUserId)
			);
		}
			
		/**
		 * Load an array of TableProjectBid objects,
		 * by ProjectId Index(es)
		 * @param integer $intProjectId
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableProjectBid[]
		*/
		public static function LoadArrayByProjectId($intProjectId, $objOptionalClauses = null) {
			// Call TableProjectBid::QueryArray to perform the LoadArrayByProjectId query
			try {
				return TableProjectBid::QueryArray(
					QQ::Equal(QQN::TableProjectBid()->ProjectId, $intProjectId),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableProjectBids
		 * by ProjectId Index(es)
		 * @param integer $intProjectId
		 * @return int
		*/
		public static function CountByProjectId($intProjectId) {
			// Call TableProjectBid::QueryCount to perform the CountByProjectId query
			return TableProjectBid::QueryCount(
				QQ::Equal(QQN::TableProjectBid()->ProjectId, $intProjectId)
			);
		}
			
		/**
		 * Load an array of TableProjectBid objects,
		 * by BuyerId Index(es)
		 * @param integer $intBuyerId
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableProjectBid[]
		*/
		public static function LoadArrayByBuyerId($intBuyerId, $objOptionalClauses = null) {
			// Call TableProjectBid::QueryArray to perform the LoadArrayByBuyerId query
			try {
				return TableProjectBid::QueryArray(
					QQ::Equal(QQN::TableProjectBid()->BuyerId, $intBuyerId),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableProjectBids
		 * by BuyerId Index(es)
		 * @param integer $intBuyerId
		 * @return int
		*/
		public static function CountByBuyerId($intBuyerId) {
			// Call TableProjectBid::QueryCount to perform the CountByBuyerId query
			return TableProjectBid::QueryCount(
				QQ::Equal(QQN::TableProjectBid()->BuyerId, $intBuyerId)
			);
		}
			
		/**
		 * Load an array of TableProjectBid objects,
		 * by Bid Index(es)
		 * @param integer $intBid
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableProjectBid[]
		*/
		public static function LoadArrayByBid($intBid, $objOptionalClauses = null) {
			// Call TableProjectBid::QueryArray to perform the LoadArrayByBid query
			try {
				return TableProjectBid::QueryArray(
					QQ::Equal(QQN::TableProjectBid()->Bid, $intBid),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableProjectBids
		 * by Bid Index(es)
		 * @param integer $intBid
		 * @return int
		*/
		public static function CountByBid($intBid) {
			// Call TableProjectBid::QueryCount to perform the CountByBid query
			return TableProjectBid::QueryCount(
				QQ::Equal(QQN::TableProjectBid()->Bid, $intBid)
			);
		}
			
		/**
		 * Load an array of TableProjectBid objects,
		 * by DayToComplete Index(es)
		 * @param integer $intDayToComplete
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableProjectBid[]
		*/
		public static function LoadArrayByDayToComplete($intDayToComplete, $objOptionalClauses = null) {
			// Call TableProjectBid::QueryArray to perform the LoadArrayByDayToComplete query
			try {
				return TableProjectBid::QueryArray(
					QQ::Equal(QQN::TableProjectBid()->DayToComplete, $intDayToComplete),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableProjectBids
		 * by DayToComplete Index(es)
		 * @param integer $intDayToComplete
		 * @return int
		*/
		public static function CountByDayToComplete($intDayToComplete) {
			// Call TableProjectBid::QueryCount to perform the CountByDayToComplete query
			return TableProjectBid::QueryCount(
				QQ::Equal(QQN::TableProjectBid()->DayToComplete, $intDayToComplete)
			);
		}
			
		/**
		 * Load an array of TableProjectBid objects,
		 * by DayPeriodBeforeStarting Index(es)
		 * @param integer $intDayPeriodBeforeStarting
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableProjectBid[]
		*/
		public static function LoadArrayByDayPeriodBeforeStarting($intDayPeriodBeforeStarting, $objOptionalClauses = null) {
			// Call TableProjectBid::QueryArray to perform the LoadArrayByDayPeriodBeforeStarting query
			try {
				return TableProjectBid::QueryArray(
					QQ::Equal(QQN::TableProjectBid()->DayPeriodBeforeStarting, $intDayPeriodBeforeStarting),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableProjectBids
		 * by DayPeriodBeforeStarting Index(es)
		 * @param integer $intDayPeriodBeforeStarting
		 * @return int
		*/
		public static function CountByDayPeriodBeforeStarting($intDayPeriodBeforeStarting) {
			// Call TableProjectBid::QueryCount to perform the CountByDayPeriodBeforeStarting query
			return TableProjectBid::QueryCount(
				QQ::Equal(QQN::TableProjectBid()->DayPeriodBeforeStarting, $intDayPeriodBeforeStarting)
			);
		}
			
		/**
		 * Load an array of TableProjectBid objects,
		 * by Sendmail Index(es)
		 * @param string $strSendmail
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableProjectBid[]
		*/
		public static function LoadArrayBySendmail($strSendmail, $objOptionalClauses = null) {
			// Call TableProjectBid::QueryArray to perform the LoadArrayBySendmail query
			try {
				return TableProjectBid::QueryArray(
					QQ::Equal(QQN::TableProjectBid()->Sendmail, $strSendmail),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableProjectBids
		 * by Sendmail Index(es)
		 * @param string $strSendmail
		 * @return int
		*/
		public static function CountBySendmail($strSendmail) {
			// Call TableProjectBid::QueryCount to perform the CountBySendmail query
			return TableProjectBid::QueryCount(
				QQ::Equal(QQN::TableProjectBid()->Sendmail, $strSendmail)
			);
		}
			
		/**
		 * Load an array of TableProjectBid objects,
		 * by BidDate Index(es)
		 * @param QDateTime $dttBidDate
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableProjectBid[]
		*/
		public static function LoadArrayByBidDate($dttBidDate, $objOptionalClauses = null) {
			// Call TableProjectBid::QueryArray to perform the LoadArrayByBidDate query
			try {
				return TableProjectBid::QueryArray(
					QQ::Equal(QQN::TableProjectBid()->BidDate, $dttBidDate),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableProjectBids
		 * by BidDate Index(es)
		 * @param QDateTime $dttBidDate
		 * @return int
		*/
		public static function CountByBidDate($dttBidDate) {
			// Call TableProjectBid::QueryCount to perform the CountByBidDate query
			return TableProjectBid::QueryCount(
				QQ::Equal(QQN::TableProjectBid()->BidDate, $dttBidDate)
			);
		}
			
		/**
		 * Load an array of TableProjectBid objects,
		 * by RetractDate Index(es)
		 * @param QDateTime $dttRetractDate
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableProjectBid[]
		*/
		public static function LoadArrayByRetractDate($dttRetractDate, $objOptionalClauses = null) {
			// Call TableProjectBid::QueryArray to perform the LoadArrayByRetractDate query
			try {
				return TableProjectBid::QueryArray(
					QQ::Equal(QQN::TableProjectBid()->RetractDate, $dttRetractDate),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableProjectBids
		 * by RetractDate Index(es)
		 * @param QDateTime $dttRetractDate
		 * @return int
		*/
		public static function CountByRetractDate($dttRetractDate) {
			// Call TableProjectBid::QueryCount to perform the CountByRetractDate query
			return TableProjectBid::QueryCount(
				QQ::Equal(QQN::TableProjectBid()->RetractDate, $dttRetractDate)
			);
		}
			
		/**
		 * Load an array of TableProjectBid objects,
		 * by Status Index(es)
		 * @param integer $intStatus
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableProjectBid[]
		*/
		public static function LoadArrayByStatus($intStatus, $objOptionalClauses = null) {
			// Call TableProjectBid::QueryArray to perform the LoadArrayByStatus query
			try {
				return TableProjectBid::QueryArray(
					QQ::Equal(QQN::TableProjectBid()->Status, $intStatus),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableProjectBids
		 * by Status Index(es)
		 * @param integer $intStatus
		 * @return int
		*/
		public static function CountByStatus($intStatus) {
			// Call TableProjectBid::QueryCount to perform the CountByStatus query
			return TableProjectBid::QueryCount(
				QQ::Equal(QQN::TableProjectBid()->Status, $intStatus)
			);
		}
			
		/**
		 * Load an array of TableProjectBid objects,
		 * by Enable Index(es)
		 * @param string $strEnable
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableProjectBid[]
		*/
		public static function LoadArrayByEnable($strEnable, $objOptionalClauses = null) {
			// Call TableProjectBid::QueryArray to perform the LoadArrayByEnable query
			try {
				return TableProjectBid::QueryArray(
					QQ::Equal(QQN::TableProjectBid()->Enable, $strEnable),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableProjectBids
		 * by Enable Index(es)
		 * @param string $strEnable
		 * @return int
		*/
		public static function CountByEnable($strEnable) {
			// Call TableProjectBid::QueryCount to perform the CountByEnable query
			return TableProjectBid::QueryCount(
				QQ::Equal(QQN::TableProjectBid()->Enable, $strEnable)
			);
		}
			
		/**
		 * Load an array of TableProjectBid objects,
		 * by UserId, ProjectId, Status Index(es)
		 * @param integer $intUserId
		 * @param integer $intProjectId
		 * @param integer $intStatus
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableProjectBid[]
		*/
		public static function LoadArrayByUserIdProjectIdStatus($intUserId, $intProjectId, $intStatus, $objOptionalClauses = null) {
			// Call TableProjectBid::QueryArray to perform the LoadArrayByUserIdProjectIdStatus query
			try {
				return TableProjectBid::QueryArray(
					QQ::AndCondition(
					QQ::Equal(QQN::TableProjectBid()->UserId, $intUserId),
					QQ::Equal(QQN::TableProjectBid()->ProjectId, $intProjectId),
					QQ::Equal(QQN::TableProjectBid()->Status, $intStatus)
					),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableProjectBids
		 * by UserId, ProjectId, Status Index(es)
		 * @param integer $intUserId
		 * @param integer $intProjectId
		 * @param integer $intStatus
		 * @return int
		*/
		public static function CountByUserIdProjectIdStatus($intUserId, $intProjectId, $intStatus) {
			// Call TableProjectBid::QueryCount to perform the CountByUserIdProjectIdStatus query
			return TableProjectBid::QueryCount(
				QQ::AndCondition(
				QQ::Equal(QQN::TableProjectBid()->UserId, $intUserId),
				QQ::Equal(QQN::TableProjectBid()->ProjectId, $intProjectId),
				QQ::Equal(QQN::TableProjectBid()->Status, $intStatus)
				)
			);
		}



		////////////////////////////////////////////////////
		// INDEX-BASED LOAD METHODS (Array via Many to Many)
		////////////////////////////////////////////////////




		//////////////////////////
		// SAVE, DELETE AND RELOAD
		//////////////////////////

		/**
		 * Save this TableProjectBid
		 * @param bool $blnForceInsert
		 * @param bool $blnForceUpdate
		 * @return int
		 */
		public function Save($blnForceInsert = false, $blnForceUpdate = false) {
			// Get the Database Object for this Class
			$objDatabase = TableProjectBid::GetDatabase();

			$mixToReturn = null;

			try {
				if ((!$this->__blnRestored) || ($blnForceInsert)) {
					// Perform an INSERT query
					$objDatabase->NonQuery('
						INSERT INTO `table_project_bid` (
							`user_id`,
							`project_id`,
							`buyer_id`,
							`bid`,
							`day_to_complete`,
							`day_period_before_starting`,
							`comment`,
							`sendmail`,
							`enable`,
							`bid_date`,
							`retract_date`,
							`won`,
							`retract`,
							`status`
						) VALUES (
							' . $objDatabase->SqlVariable($this->intUserId) . ',
							' . $objDatabase->SqlVariable($this->intProjectId) . ',
							' . $objDatabase->SqlVariable($this->intBuyerId) . ',
							' . $objDatabase->SqlVariable($this->intBid) . ',
							' . $objDatabase->SqlVariable($this->intDayToComplete) . ',
							' . $objDatabase->SqlVariable($this->intDayPeriodBeforeStarting) . ',
							' . $objDatabase->SqlVariable($this->strComment) . ',
							' . $objDatabase->SqlVariable($this->strSendmail) . ',
							' . $objDatabase->SqlVariable($this->strEnable) . ',
							' . $objDatabase->SqlVariable($this->dttBidDate) . ',
							' . $objDatabase->SqlVariable($this->dttRetractDate) . ',
							' . $objDatabase->SqlVariable($this->strWon) . ',
							' . $objDatabase->SqlVariable($this->strRetract) . ',
							' . $objDatabase->SqlVariable($this->intStatus) . '
						)
					');

					// Update Identity column and return its value
					$mixToReturn = $this->intId = $objDatabase->InsertId('table_project_bid', 'id');
				} else {
					// Perform an UPDATE query

					// First checking for Optimistic Locking constraints (if applicable)

					// Perform the UPDATE query
					$objDatabase->NonQuery('
						UPDATE
							`table_project_bid`
						SET
							`user_id` = ' . $objDatabase->SqlVariable($this->intUserId) . ',
							`project_id` = ' . $objDatabase->SqlVariable($this->intProjectId) . ',
							`buyer_id` = ' . $objDatabase->SqlVariable($this->intBuyerId) . ',
							`bid` = ' . $objDatabase->SqlVariable($this->intBid) . ',
							`day_to_complete` = ' . $objDatabase->SqlVariable($this->intDayToComplete) . ',
							`day_period_before_starting` = ' . $objDatabase->SqlVariable($this->intDayPeriodBeforeStarting) . ',
							`comment` = ' . $objDatabase->SqlVariable($this->strComment) . ',
							`sendmail` = ' . $objDatabase->SqlVariable($this->strSendmail) . ',
							`enable` = ' . $objDatabase->SqlVariable($this->strEnable) . ',
							`bid_date` = ' . $objDatabase->SqlVariable($this->dttBidDate) . ',
							`retract_date` = ' . $objDatabase->SqlVariable($this->dttRetractDate) . ',
							`won` = ' . $objDatabase->SqlVariable($this->strWon) . ',
							`retract` = ' . $objDatabase->SqlVariable($this->strRetract) . ',
							`status` = ' . $objDatabase->SqlVariable($this->intStatus) . '
						WHERE
							`id` = ' . $objDatabase->SqlVariable($this->intId) . '
					');
				}

			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Update __blnRestored and any Non-Identity PK Columns (if applicable)
			$this->__blnRestored = true;


			// Return 
			return $mixToReturn;
		}

		/**
		 * Delete this TableProjectBid
		 * @return void
		 */
		public function Delete() {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Cannot delete this TableProjectBid with an unset primary key.');

			// Get the Database Object for this Class
			$objDatabase = TableProjectBid::GetDatabase();


			// Perform the SQL Query
			$objDatabase->NonQuery('
				DELETE FROM
					`table_project_bid`
				WHERE
					`id` = ' . $objDatabase->SqlVariable($this->intId) . '');
		}

		/**
		 * Delete all TableProjectBids
		 * @return void
		 */
		public static function DeleteAll() {
			// Get the Database Object for this Class
			$objDatabase = TableProjectBid::GetDatabase();

			// Perform the Query
			$objDatabase->NonQuery('
				DELETE FROM
					`table_project_bid`');
		}

		/**
		 * Truncate table_project_bid table
		 * @return void
		 */
		public static function Truncate() {
			// Get the Database Object for this Class
			$objDatabase = TableProjectBid::GetDatabase();

			// Perform the Query
			$objDatabase->NonQuery('
				TRUNCATE `table_project_bid`');
		}

		/**
		 * Reload this TableProjectBid from the database.
		 * @return void
		 */
		public function Reload() {
			// Make sure we are actually Restored from the database
			if (!$this->__blnRestored)
				throw new QCallerException('Cannot call Reload() on a new, unsaved TableProjectBid object.');

			// Reload the Object
			$objReloaded = TableProjectBid::Load($this->intId);

			// Update $this's local variables to match
			$this->UserId = $objReloaded->UserId;
			$this->ProjectId = $objReloaded->ProjectId;
			$this->intBuyerId = $objReloaded->intBuyerId;
			$this->intBid = $objReloaded->intBid;
			$this->intDayToComplete = $objReloaded->intDayToComplete;
			$this->intDayPeriodBeforeStarting = $objReloaded->intDayPeriodBeforeStarting;
			$this->strComment = $objReloaded->strComment;
			$this->strSendmail = $objReloaded->strSendmail;
			$this->strEnable = $objReloaded->strEnable;
			$this->dttBidDate = $objReloaded->dttBidDate;
			$this->dttRetractDate = $objReloaded->dttRetractDate;
			$this->strWon = $objReloaded->strWon;
			$this->strRetract = $objReloaded->strRetract;
			$this->intStatus = $objReloaded->intStatus;
		}



		////////////////////
		// PUBLIC OVERRIDERS
		////////////////////

				/**
		 * Override method to perform a property "Get"
		 * This will get the value of $strName
		 *
		 * @param string $strName Name of the property to get
		 * @return mixed
		 */
		public function __get($strName) {
			switch ($strName) {
				///////////////////
				// Member Variables
				///////////////////
				case 'Id':
					/**
					 * Gets the value for intId (Read-Only PK)
					 * @return integer
					 */
					return $this->intId;

				case 'UserId':
					/**
					 * Gets the value for intUserId (Not Null)
					 * @return integer
					 */
					return $this->intUserId;

				case 'ProjectId':
					/**
					 * Gets the value for intProjectId (Not Null)
					 * @return integer
					 */
					return $this->intProjectId;

				case 'BuyerId':
					/**
					 * Gets the value for intBuyerId (Not Null)
					 * @return integer
					 */
					return $this->intBuyerId;

				case 'Bid':
					/**
					 * Gets the value for intBid (Not Null)
					 * @return integer
					 */
					return $this->intBid;

				case 'DayToComplete':
					/**
					 * Gets the value for intDayToComplete (Not Null)
					 * @return integer
					 */
					return $this->intDayToComplete;

				case 'DayPeriodBeforeStarting':
					/**
					 * Gets the value for intDayPeriodBeforeStarting (Not Null)
					 * @return integer
					 */
					return $this->intDayPeriodBeforeStarting;

				case 'Comment':
					/**
					 * Gets the value for strComment 
					 * @return string
					 */
					return $this->strComment;

				case 'Sendmail':
					/**
					 * Gets the value for strSendmail 
					 * @return string
					 */
					return $this->strSendmail;

				case 'Enable':
					/**
					 * Gets the value for strEnable (Not Null)
					 * @return string
					 */
					return $this->strEnable;

				case 'BidDate':
					/**
					 * Gets the value for dttBidDate 
					 * @return QDateTime
					 */
					return $this->dttBidDate;

				case 'RetractDate':
					/**
					 * Gets the value for dttRetractDate 
					 * @return QDateTime
					 */
					return $this->dttRetractDate;

				case 'Won':
					/**
					 * Gets the value for strWon 
					 * @return string
					 */
					return $this->strWon;

				case 'Retract':
					/**
					 * Gets the value for strRetract 
					 * @return string
					 */
					return $this->strRetract;

				case 'Status':
					/**
					 * Gets the value for intStatus (Not Null)
					 * @return integer
					 */
					return $this->intStatus;


				///////////////////
				// Member Objects
				///////////////////
				case 'User':
					/**
					 * Gets the value for the TableUserProject object referenced by intUserId (Not Null)
					 * @return TableUserProject
					 */
					try {
						if ((!$this->objUser) && (!is_null($this->intUserId)))
							$this->objUser = TableUserProject::Load($this->intUserId);
						return $this->objUser;
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Project':
					/**
					 * Gets the value for the TableProject object referenced by intProjectId (Not Null)
					 * @return TableProject
					 */
					try {
						if ((!$this->objProject) && (!is_null($this->intProjectId)))
							$this->objProject = TableProject::Load($this->intProjectId);
						return $this->objProject;
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}


				////////////////////////////
				// Virtual Object References (Many to Many and Reverse References)
				// (If restored via a "Many-to" expansion)
				////////////////////////////


				case '__Restored':
					return $this->__blnRestored;

				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

				/**
		 * Override method to perform a property "Set"
		 * This will set the property $strName to be $mixValue
		 *
		 * @param string $strName Name of the property to set
		 * @param string $mixValue New value of the property
		 * @return mixed
		 */
		public function __set($strName, $mixValue) {
			switch ($strName) {
				///////////////////
				// Member Variables
				///////////////////
				case 'UserId':
					/**
					 * Sets the value for intUserId (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						$this->objUser = null;
						return ($this->intUserId = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'ProjectId':
					/**
					 * Sets the value for intProjectId (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						$this->objProject = null;
						return ($this->intProjectId = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'BuyerId':
					/**
					 * Sets the value for intBuyerId (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intBuyerId = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Bid':
					/**
					 * Sets the value for intBid (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intBid = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'DayToComplete':
					/**
					 * Sets the value for intDayToComplete (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intDayToComplete = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'DayPeriodBeforeStarting':
					/**
					 * Sets the value for intDayPeriodBeforeStarting (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intDayPeriodBeforeStarting = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Comment':
					/**
					 * Sets the value for strComment 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strComment = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Sendmail':
					/**
					 * Sets the value for strSendmail 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strSendmail = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Enable':
					/**
					 * Sets the value for strEnable (Not Null)
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strEnable = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'BidDate':
					/**
					 * Sets the value for dttBidDate 
					 * @param QDateTime $mixValue
					 * @return QDateTime
					 */
					try {
						return ($this->dttBidDate = QType::Cast($mixValue, QType::DateTime));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'RetractDate':
					/**
					 * Sets the value for dttRetractDate 
					 * @param QDateTime $mixValue
					 * @return QDateTime
					 */
					try {
						return ($this->dttRetractDate = QType::Cast($mixValue, QType::DateTime));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Won':
					/**
					 * Sets the value for strWon 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strWon = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Retract':
					/**
					 * Sets the value for strRetract 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strRetract = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Status':
					/**
					 * Sets the value for intStatus (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intStatus = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}


				///////////////////
				// Member Objects
				///////////////////
				case 'User':
					/**
					 * Sets the value for the TableUserProject object referenced by intUserId (Not Null)
					 * @param TableUserProject $mixValue
					 * @return TableUserProject
					 */
					if (is_null($mixValue)) {
						$this->intUserId = null;
						$this->objUser = null;
						return null;
					} else {
						// Make sure $mixValue actually is a TableUserProject object
						try {
							$mixValue = QType::Cast($mixValue, 'TableUserProject');
						} catch (QInvalidCastException $objExc) {
							$objExc->IncrementOffset();
							throw $objExc;
						} 

						// Make sure $mixValue is a SAVED TableUserProject object
						if (is_null($mixValue->Id))
							throw new QCallerException('Unable to set an unsaved User for this TableProjectBid');

						// Update Local Member Variables
						$this->objUser = $mixValue;
						$this->intUserId = $mixValue->Id;

						// Return $mixValue
						return $mixValue;
					}
					break;

				case 'Project':
					/**
					 * Sets the value for the TableProject object referenced by intProjectId (Not Null)
					 * @param TableProject $mixValue
					 * @return TableProject
					 */
					if (is_null($mixValue)) {
						$this->intProjectId = null;
						$this->objProject = null;
						return null;
					} else {
						// Make sure $mixValue actually is a TableProject object
						try {
							$mixValue = QType::Cast($mixValue, 'TableProject');
						} catch (QInvalidCastException $objExc) {
							$objExc->IncrementOffset();
							throw $objExc;
						} 

						// Make sure $mixValue is a SAVED TableProject object
						if (is_null($mixValue->Id))
							throw new QCallerException('Unable to set an unsaved Project for this TableProjectBid');

						// Update Local Member Variables
						$this->objProject = $mixValue;
						$this->intProjectId = $mixValue->Id;

						// Return $mixValue
						return $mixValue;
					}
					break;

				default:
					try {
						return parent::__set($strName, $mixValue);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/**
		 * Lookup a VirtualAttribute value (if applicable).  Returns NULL if none found.
		 * @param string $strName
		 * @return string
		 */
		public function GetVirtualAttribute($strName) {
			if (array_key_exists($strName, $this->__strVirtualAttributeArray))
				return $this->__strVirtualAttributeArray[$strName];
			return null;
		}



		///////////////////////////////
		// ASSOCIATED OBJECTS' METHODS
		///////////////////////////////





		////////////////////////////////////////
		// METHODS for SOAP-BASED WEB SERVICES
		////////////////////////////////////////

		public static function GetSoapComplexTypeXml() {
			$strToReturn = '<complexType name="TableProjectBid"><sequence>';
			$strToReturn .= '<element name="Id" type="xsd:int"/>';
			$strToReturn .= '<element name="User" type="xsd1:TableUserProject"/>';
			$strToReturn .= '<element name="Project" type="xsd1:TableProject"/>';
			$strToReturn .= '<element name="BuyerId" type="xsd:int"/>';
			$strToReturn .= '<element name="Bid" type="xsd:int"/>';
			$strToReturn .= '<element name="DayToComplete" type="xsd:int"/>';
			$strToReturn .= '<element name="DayPeriodBeforeStarting" type="xsd:int"/>';
			$strToReturn .= '<element name="Comment" type="xsd:string"/>';
			$strToReturn .= '<element name="Sendmail" type="xsd:string"/>';
			$strToReturn .= '<element name="Enable" type="xsd:string"/>';
			$strToReturn .= '<element name="BidDate" type="xsd:dateTime"/>';
			$strToReturn .= '<element name="RetractDate" type="xsd:dateTime"/>';
			$strToReturn .= '<element name="Won" type="xsd:string"/>';
			$strToReturn .= '<element name="Retract" type="xsd:string"/>';
			$strToReturn .= '<element name="Status" type="xsd:int"/>';
			$strToReturn .= '<element name="__blnRestored" type="xsd:boolean"/>';
			$strToReturn .= '</sequence></complexType>';
			return $strToReturn;
		}

		public static function AlterSoapComplexTypeArray(&$strComplexTypeArray) {
			if (!array_key_exists('TableProjectBid', $strComplexTypeArray)) {
				$strComplexTypeArray['TableProjectBid'] = TableProjectBid::GetSoapComplexTypeXml();
				TableUserProject::AlterSoapComplexTypeArray($strComplexTypeArray);
				TableProject::AlterSoapComplexTypeArray($strComplexTypeArray);
			}
		}

		public static function GetArrayFromSoapArray($objSoapArray) {
			$objArrayToReturn = array();

			foreach ($objSoapArray as $objSoapObject)
				array_push($objArrayToReturn, TableProjectBid::GetObjectFromSoapObject($objSoapObject));

			return $objArrayToReturn;
		}

		public static function GetObjectFromSoapObject($objSoapObject) {
			$objToReturn = new TableProjectBid();
			if (property_exists($objSoapObject, 'Id'))
				$objToReturn->intId = $objSoapObject->Id;
			if ((property_exists($objSoapObject, 'User')) &&
				($objSoapObject->User))
				$objToReturn->User = TableUserProject::GetObjectFromSoapObject($objSoapObject->User);
			if ((property_exists($objSoapObject, 'Project')) &&
				($objSoapObject->Project))
				$objToReturn->Project = TableProject::GetObjectFromSoapObject($objSoapObject->Project);
			if (property_exists($objSoapObject, 'BuyerId'))
				$objToReturn->intBuyerId = $objSoapObject->BuyerId;
			if (property_exists($objSoapObject, 'Bid'))
				$objToReturn->intBid = $objSoapObject->Bid;
			if (property_exists($objSoapObject, 'DayToComplete'))
				$objToReturn->intDayToComplete = $objSoapObject->DayToComplete;
			if (property_exists($objSoapObject, 'DayPeriodBeforeStarting'))
				$objToReturn->intDayPeriodBeforeStarting = $objSoapObject->DayPeriodBeforeStarting;
			if (property_exists($objSoapObject, 'Comment'))
				$objToReturn->strComment = $objSoapObject->Comment;
			if (property_exists($objSoapObject, 'Sendmail'))
				$objToReturn->strSendmail = $objSoapObject->Sendmail;
			if (property_exists($objSoapObject, 'Enable'))
				$objToReturn->strEnable = $objSoapObject->Enable;
			if (property_exists($objSoapObject, 'BidDate'))
				$objToReturn->dttBidDate = new QDateTime($objSoapObject->BidDate);
			if (property_exists($objSoapObject, 'RetractDate'))
				$objToReturn->dttRetractDate = new QDateTime($objSoapObject->RetractDate);
			if (property_exists($objSoapObject, 'Won'))
				$objToReturn->strWon = $objSoapObject->Won;
			if (property_exists($objSoapObject, 'Retract'))
				$objToReturn->strRetract = $objSoapObject->Retract;
			if (property_exists($objSoapObject, 'Status'))
				$objToReturn->intStatus = $objSoapObject->Status;
			if (property_exists($objSoapObject, '__blnRestored'))
				$objToReturn->__blnRestored = $objSoapObject->__blnRestored;
			return $objToReturn;
		}

		public static function GetSoapArrayFromArray($objArray) {
			if (!$objArray)
				return null;

			$objArrayToReturn = array();

			foreach ($objArray as $objObject)
				array_push($objArrayToReturn, TableProjectBid::GetSoapObjectFromObject($objObject, true));

			return unserialize(serialize($objArrayToReturn));
		}

		public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) {
			if ($objObject->objUser)
				$objObject->objUser = TableUserProject::GetSoapObjectFromObject($objObject->objUser, false);
			else if (!$blnBindRelatedObjects)
				$objObject->intUserId = null;
			if ($objObject->objProject)
				$objObject->objProject = TableProject::GetSoapObjectFromObject($objObject->objProject, false);
			else if (!$blnBindRelatedObjects)
				$objObject->intProjectId = null;
			if ($objObject->dttBidDate)
				$objObject->dttBidDate = $objObject->dttBidDate->__toString(QDateTime::FormatSoap);
			if ($objObject->dttRetractDate)
				$objObject->dttRetractDate = $objObject->dttRetractDate->__toString(QDateTime::FormatSoap);
			return $objObject;
		}




	}



	/////////////////////////////////////
	// ADDITIONAL CLASSES for QCubed QUERY
	/////////////////////////////////////

	class QQNodeTableProjectBid extends QQNode {
		protected $strTableName = 'table_project_bid';
		protected $strPrimaryKey = 'id';
		protected $strClassName = 'TableProjectBid';
		public function __get($strName) {
			switch ($strName) {
				case 'Id':
					return new QQNode('id', 'Id', 'integer', $this);
				case 'UserId':
					return new QQNode('user_id', 'UserId', 'integer', $this);
				case 'User':
					return new QQNodeTableUserProject('user_id', 'User', 'integer', $this);
				case 'ProjectId':
					return new QQNode('project_id', 'ProjectId', 'integer', $this);
				case 'Project':
					return new QQNodeTableProject('project_id', 'Project', 'integer', $this);
				case 'BuyerId':
					return new QQNode('buyer_id', 'BuyerId', 'integer', $this);
				case 'Bid':
					return new QQNode('bid', 'Bid', 'integer', $this);
				case 'DayToComplete':
					return new QQNode('day_to_complete', 'DayToComplete', 'integer', $this);
				case 'DayPeriodBeforeStarting':
					return new QQNode('day_period_before_starting', 'DayPeriodBeforeStarting', 'integer', $this);
				case 'Comment':
					return new QQNode('comment', 'Comment', 'string', $this);
				case 'Sendmail':
					return new QQNode('sendmail', 'Sendmail', 'string', $this);
				case 'Enable':
					return new QQNode('enable', 'Enable', 'string', $this);
				case 'BidDate':
					return new QQNode('bid_date', 'BidDate', 'QDateTime', $this);
				case 'RetractDate':
					return new QQNode('retract_date', 'RetractDate', 'QDateTime', $this);
				case 'Won':
					return new QQNode('won', 'Won', 'string', $this);
				case 'Retract':
					return new QQNode('retract', 'Retract', 'string', $this);
				case 'Status':
					return new QQNode('status', 'Status', 'integer', $this);

				case '_PrimaryKeyNode':
					return new QQNode('id', 'Id', 'integer', $this);
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}
	}

	class QQReverseReferenceNodeTableProjectBid extends QQReverseReferenceNode {
		protected $strTableName = 'table_project_bid';
		protected $strPrimaryKey = 'id';
		protected $strClassName = 'TableProjectBid';
		public function __get($strName) {
			switch ($strName) {
				case 'Id':
					return new QQNode('id', 'Id', 'integer', $this);
				case 'UserId':
					return new QQNode('user_id', 'UserId', 'integer', $this);
				case 'User':
					return new QQNodeTableUserProject('user_id', 'User', 'integer', $this);
				case 'ProjectId':
					return new QQNode('project_id', 'ProjectId', 'integer', $this);
				case 'Project':
					return new QQNodeTableProject('project_id', 'Project', 'integer', $this);
				case 'BuyerId':
					return new QQNode('buyer_id', 'BuyerId', 'integer', $this);
				case 'Bid':
					return new QQNode('bid', 'Bid', 'integer', $this);
				case 'DayToComplete':
					return new QQNode('day_to_complete', 'DayToComplete', 'integer', $this);
				case 'DayPeriodBeforeStarting':
					return new QQNode('day_period_before_starting', 'DayPeriodBeforeStarting', 'integer', $this);
				case 'Comment':
					return new QQNode('comment', 'Comment', 'string', $this);
				case 'Sendmail':
					return new QQNode('sendmail', 'Sendmail', 'string', $this);
				case 'Enable':
					return new QQNode('enable', 'Enable', 'string', $this);
				case 'BidDate':
					return new QQNode('bid_date', 'BidDate', 'QDateTime', $this);
				case 'RetractDate':
					return new QQNode('retract_date', 'RetractDate', 'QDateTime', $this);
				case 'Won':
					return new QQNode('won', 'Won', 'string', $this);
				case 'Retract':
					return new QQNode('retract', 'Retract', 'string', $this);
				case 'Status':
					return new QQNode('status', 'Status', 'integer', $this);

				case '_PrimaryKeyNode':
					return new QQNode('id', 'Id', 'integer', $this);
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}
	}

?>